package com.sun.androidexerciseproject.widget.activity.ui;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.sun.androidexerciseproject.widget.R;

import static com.sun.androidexerciseproject.widget.activity.ui.SearchableActivity.JARGON;

public class SearchOtherActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_other);
        initView();
    }

    @Override
    public boolean onSearchRequested() {
        Log.d("junfutong", "onSearchRequested");
        Bundle appData = new Bundle();
        appData.putBoolean(JARGON, true);
        startSearch(null, false, appData, false);
        return super.onSearchRequested();
    }

    private void initView() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
        setSupportActionBar(toolbar);
//        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_setting, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_fav:
                onSearchRequested();
                return true;
            case R.id.action_setting:
                return true;
//            case R.id.item_search:
//                onSearchRequested();
//                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}
